const { Model, DataTypes } = require('sequelize');

const sequelize = require('./database');
const Province = require('./province');


class City extends Model {}

City.init({
  
  provinceId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: Province, // 指定关联的模型
      key: 'provinceId'
    }
  },
  cityname: {
    type: DataTypes.STRING,
    allowNull: false, 
    unique: true
  }
}, {
  sequelize,
  modelName: 'city'
});
City.belongsTo(Province,{ foreignKey: 'provinceId' })

module.exports = City;